#pragma once

#include "GraphicsDefs.h"
#include "Object.h"

class VertexBuffer : public Object
{
public:
    explicit VertexBuffer(Context* context);
    ~VertexBuffer() override;

    void SetVertexSize(unsigned size);
    void Release();

    bool SetSize(unsigned vertexCount, bool dynamic = false);

    bool SetData(const void* data);
    bool SetDataRange(const void* data, unsigned start, unsigned count, bool discard = false);
    bool IsDynamic() const { return dynamic_; }

    unsigned GetVertexCount() const { return vertexCount_; }
    unsigned GetVertexSize() const { return vertexSize_; }
    unsigned GetGpuObject() const { return vbo_; }
	unsigned char* GetData() const { return data_; }
private:
   
    bool Create();
  
    bool UpdateToGPU();

    unsigned vertexCount_{};
    unsigned vertexSize_{};
 
    bool dynamic_{};
    unsigned vbo_{ 0 };
    unsigned char* data_{};
};

